from rest_framework import serializers

from goods.models import SKUImage, SKU


class ImageSerializer(serializers.ModelSerializer):
    sku = serializers.PrimaryKeyRelatedField(read_only=True)

    class Meta:
        model = SKUImage
        fields = ('id', 'sku', 'image')


class SKUSerializer(serializers.ModelSerializer):
    """
        商品表序列化器
    """
    class Meta:
        model = SKU
        fields = ('id', 'name')